package com.jx.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import com.jx.dao.FindAllDepDao;
import com.jx.dao.FindFuncByDidDao;
import com.jx.dao.FindFuncsDao;
import com.jx.daoimpl.FindAllDepDaoImpl;
import com.jx.daoimpl.FindFuncByDidDaoimpl;
import com.jx.daoimpl.FindFuncsDaoImpl;
import com.jx.model.Dep;
import com.jx.model.Func;


public class ShowMainController extends HttpServlet{
	FindFuncsDao ffd=new FindFuncsDaoImpl();
	FindAllDepDao fadd=new FindAllDepDaoImpl();
       @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    	// TODO Auto-generated method stub
    	doPost(req, resp);
    }
       @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    	// TODO Auto-generated method stub
    	   
   			//找出所有功能
   			List<Func> funcs=ffd.findFuncsDao(0,ffd.findTotalFuncs());
   			req.getSession().setAttribute("funcs",funcs);
   			List<Dep> deps= fadd.findAllDeoDao(0,fadd.findTotalDep());
   			req.getSession().setAttribute("deps", deps);

   			
   			req.getRequestDispatcher("main.jsp").forward(req, resp);
    }
}
